package com.twu.biblioteca;

import java.util.List;

/**
 * Created by sravanns on 12/06/14.
 */
/* Job: represents all available books yet to be checked out from library */
public class ListBooks implements MenuAction {
    private Library library;
    private UserInterface userInterface;



    ListBooks(Library obj, UserInterface ui) {
        library = obj;
        userInterface=ui;
    }

    @Override
    public String toString() {
        return "List Books";
    }

    @Override
    public Result performAction(String user) {
        String input = "";
        List<Book> availableBooks = library.getAvailableBooks();
        Result result = new Result();
        if (availableBooks.size() == 0) {
            result.setResult("No Books", false);
            return result;
        }

        userInterface.displayBooks(availableBooks);

        result.setResult("listed "+availableBooks.size()+" books",true);
        return result;
    }
}

